public class Demo1 {
    static double volume(double a, double b, double c){
        if(a+b<c || b+c<a) {
            throw new TriangleException("不能构成三角形");
        }
        double s = (a+b+c)/2;
        return Math.sqrt(s*(s-a)*(s-b)*(s-c));
    }
    static double perimeter(double a, double b, double c){
        if(a+b<=c || b+c<=a) {
            throw new TriangleException("不能构成三角形");
        }
        return a+b+c;
    }

    public static void main(String[] args) {
        try{
            double a = volume(1,4,5);
            double b = perimeter(1,4,5);
            System.out.println("周长="+b+" 体积="+a);
        }catch (TriangleException e){
            e.printStackTrace();
        }
    }
}
class TriangleException extends RuntimeException{
    public TriangleException() {
    }
    public TriangleException(String message) {
        super(message);
    }
}
